package com.tianhui.consignortwofei.widget;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.fgs.common.CommonDialog;
import com.tianhui.consignortwofei.R;

/**
 * @author fgs
 * @date 2019/8/5
 **/
public class AuthTipDialog extends CommonDialog {
    private ImageView imageView;
    private String tip;
    private int imageId;
    private TextView textView;
    private TextView tipTextView;
    private TextView takePhotoTextView;
    private TextView selectPhotoTextView;
    private TextView cancelTextView;
    private View.OnClickListener takePhotoClick;
    private View.OnClickListener selectPhotoClick;


    public AuthTipDialog(Context context) {
        super(context, R.style.style_select_dialog);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_auth_tip);


        Window window = this.getWindow();
        window.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);

        imageView = findViewById(R.id.dialog_auth_tip_imageView);
        textView = findViewById(R.id.dialog_auth_tip_textView);
        tipTextView = findViewById(R.id.dialog_auth_tip_tipTextView);
        takePhotoTextView = findViewById(R.id.dialog_auth_tip_takePhotoTextView);
        selectPhotoTextView = findViewById(R.id.dialog_auth_tip_selectPhotoTextView);
        cancelTextView = findViewById(R.id.dialog_auth_tip_cancelTextView);


        takePhotoTextView.setOnClickListener(takePhotoClick);

        selectPhotoTextView.setOnClickListener(selectPhotoClick);
        cancelTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        if (imageId != 0) {
            imageView.setImageResource(imageId);
        } else {
            tipTextView.setVisibility(View.GONE);
            textView.setVisibility(View.GONE);
            imageView.setVisibility(View.GONE);
        }

    }

    public void takePhotoClick(View.OnClickListener onClickListener) {
        takePhotoClick = onClickListener;

    }

    public void selectPhotoClick(View.OnClickListener onClickListener) {
        selectPhotoClick = onClickListener;
    }

    public void setImage(int imageId) {
        this.imageId = imageId;
    }

//    public static class Builder {
//        private ImageView imageView;
//        private String tip;
//        private Context context;
//        private TextView tipTextView;
//        private TextView takePhotoTextView;
//        private TextView selectPhotoTextView;
//        private TextView cancelTextView;
//
//        public Builder builder(Context context) {
//            this.context = context;
//            return this;
//        }
//
//        public void setImageView(int imageId) {
//            if (imageId != 0) {
//                imageView.setImageResource(imageId);
//            }
//        }
//
//        public void setTip(String tip) {
//            tipTextView.setText(tip);
//        }
//
//
//        public void onTakePhoto(OcrScanCallback ocrScanCallback, IOcrScanType iOcrScanType) {
//            OcrScan.init().ocrScan(getContext(), ocrScanCallback, iOcrScanType);
//
//        }
//
//        public void onSelectPhoto(OcrScanCallback ocrScanCallback, IOcrScanType iOcrScanType) {
//            OcrScan.init().ocrScanSelectPhoto(getContext(), ocrScanCallback, iOcrScanType);
//        }
//
//        public AuthTipDialog create(){
//
//        }
//    }

}
